package com.aloda.config;

import com.aloda.properties.AiProperties;
import com.volcengine.ark.runtime.service.ArkService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

@Slf4j
@Configuration
public class VolcanoAiConfig {

    @Resource
    private AiProperties aiProperties;

    @Bean
    public ArkService getArkService() {
        log.info("开始初始化火山引擎AI客户端...");
        String apiKey = aiProperties.getVolcanoApiKey();
        return ArkService.builder()
                .apiKey(apiKey) // apiKey
                .timeout(Duration.ofSeconds(120)) // 超时时间
                .connectTimeout(Duration.ofSeconds(20)) // 连接超时时间
                .retryTimes(2) // 重试次数
                .build();
    }
}
